home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 8 / QRZ Ham Radio Callsign Database - Volume 8.iso / mac / files / p_msys / msysb116.exe / SCAN735.ASM < prev    next >
Assembly Source File  |  1993-11-27  |  8KB  |  264 lines

  1. ; scan735.asm
  2.  
  3. ;       Here is sample source for a Scan TSR to be used with the MSYS
  4. ;       Pactor scan command
  5.  
  6. ;       This example is for the ICOM IC-735. It may work for other
  7. ;       ICOM HF radios with minor modification. The IC-735 requires 
  8. ;       the following command format:   
  9. ;           FE FE 00 tt cc data FD
  10. ;       where tt is the transmitter address which is model dependent:
  11. ;               IC-275  16
  12. ;               IC-375  18
  13. ;               IC-475  20
  14. ;               IC-575  22
  15. ;               IC-735  04
  16. ;               IC-751  28
  17. ;               IC-761  30
  18. ;                       Verify these in your instruction book!
  19. ;
  20. ;       cc is the control code for the operation to perform (00 to
  21. ;       set frequency) and data is the parameters needed for the
  22. ;       particular command. The other values are hex bytes that
  23. ;       must be as shown.
  24. ;
  25. ;       For command 00, the frequency is given in 4 bytes, using
  26. ;       BCD (binary coded decimal) with the least significant byte
  27. ;       first. The frequency is expressed in Hz. Thus, for a frequency
  28. ;       of 14,123.450 KHz, the four bytes would be
  29. ;               50 34 12 14
  30. ;
  31. ;       The complete set of 10 bytes used to set a frequency of 7.021 MHz
  32. ;       would be (in hex):
  33. ;               FE FE 00 04 00 00 10 02 07 FD
  34. ;       to produce the executable for this program, use the following
  35. ;
  36. ;       asm     scan735.asm     {tasm or masm may be used}
  37. ;       link    scan735;
  38. ;       exe2bin scan735         {makes .com file out of .exe file}
  39.  
  40.  
  41. code    segment
  42.         assume  cs:code,ds:code
  43.  
  44. main    proc    far
  45.         org     0
  46. segorg  equ     $
  47.         org     100h
  48. start:  jmp     install
  49.  
  50.  
  51. port    dw      0               ;control uart base address
  52. ten     dw      10              ;divisor
  53. thousand dw     1000
  54. cmd     db      0FEh,0FEh
  55.         db      00
  56.         db      04              ;the tt value, 04 for the IC-735
  57.         db      00              ;the cc value - set frequency
  58. freq    db      'freq'          ;frequency in BCD, LSB first
  59.         db      0FDh
  60.  
  61. temp    db      'hhhkkkmm'      ;work space build freq
  62. savequot dw     0
  63.  
  64. ;debug   db      'xx $'
  65.  
  66. putser  proc near
  67. ;       send char in AL
  68.         push    dx
  69.         push    ax
  70.         mov     dx,port
  71.         add     dx,5            ;line status register
  72. wait1:  in      al,dx
  73.         and     al,20h          ;check transmit holding reg 
  74.         jz      wait1           ;not ready yet
  75.         pop     ax
  76.         mov     dx,port
  77.         out     dx,al           ;send char to serial port
  78.  
  79.  
  80. ;       The following commented out lines were used for debugging. They
  81. ;       displayed each byte sent to the radio in hex. 
  82. ;        push    ax
  83. ;        push    bx
  84. ;        push    cx
  85. ;        push    dx
  86. ;        mov     ah,al
  87. ;        mov     cl,4
  88. ;        shr     al,cl
  89. ;        add     al,'0'
  90. ;        cmp     al,'9'
  91. ;        jle     q1
  92. ;        add     al,7
  93. ;q1:
  94. ;        mov     debug,al
  95. ;        and     ah,15
  96. ;        add     ah,'0'
  97. ;        cmp     ah,'9'
  98. ;        jle     q2
  99. ;        add     ah,7
  100. ;q2:
  101. ;        mov     debug+1,ah
  102. ;        mov     dx,offset debug
  103. ;        mov     ah,9
  104. ;        int     21h
  105. ;        pop     dx
  106. ;        pop     cx
  107. ;        pop     bx
  108. ;        pop     ax
  109.  
  110.         pop     dx
  111.         ret
  112. putser  endp
  113.  
  114. putserstr proc near
  115. ;       sends string pointed to by bx, cx has number of bytes
  116.         push    ax
  117.         push    bx
  118.         push    cx
  119. psloop:
  120.         mov     al, byte ptr [bx]
  121.         call    putser
  122.         inc     bx
  123.         dec     cx
  124.         cmp     cx,0
  125.         je      putserstrexit
  126.         jmp     psloop
  127. putserstrexit:
  128.         pop     cx
  129.         pop     bx
  130.         pop     ax
  131.         ret
  132. putserstr endp
  133.  
  134.  
  135.  
  136. handler:
  137.         STI                     ; enable interrupts
  138. ;                               ; If we don't we will get overruns
  139. ;                               ; on the serial ports for the tnc's
  140.         push    ds              ; save some registers
  141.         push    ax
  142.         push    ax              ; save ax a second time
  143.         mov     ax,cs
  144.         mov     ds,ax           ; set up ds
  145.         pop     ax              ; get back the ax we were called with
  146.  
  147. ;
  148. ;       upon entry, dx has port address
  149. ;                   ax has high order part of frequency
  150. ;                   bx has low order part of frequency
  151.         mov     port,dx
  152.  
  153.  
  154. ; div divides DX:AX giving quot in AX, rem in DX
  155.         mov     dx,ax
  156.         mov     ax,bx   
  157. ;       We have a bit of a problem in that the DIV instruction 
  158. ;       requires that the quotient will fit in a 16 bit register.
  159. ;       But a frequency like 14.350, which is 14350000 in the 
  160. ;       long (32 bit) variable and when divided by 10 the 
  161. ;       quotient won't fit in 16 bits (AX). 
  162. ;
  163. ;       So here is what we will do...
  164. ;       First divide the original frequency by 1000. This will
  165. ;       give a quotient <= 30000 which will fit.
  166. ;       The remainder from this division will be run thru the
  167. ;       divide by 10 to get the digits loop three times.
  168. ;       Then we take the quotient and use the same instructions
  169. ;       to do the other 5 required digits
  170.  
  171.         div     thousand        ;rem in dx, quot in ax
  172.         mov     savequot,ax
  173.         mov     ax,dx           ;set up for divide
  174.         sub     dx,dx
  175.         
  176.         mov     cx,3                    ;number of digits
  177.         mov     bx,offset temp          ;place for first
  178.  
  179. dloop1:
  180.         div     ten
  181.         add     dl,'0'                  ;convert to ascii
  182.         mov     byte ptr [bx],dl
  183.         sub     dx,dx
  184.         inc     bx
  185.         dec     cx
  186.         cmp     cx,0
  187.         jne     dloop1
  188.         
  189.         mov     ax,savequot
  190.         sub     dx,dx
  191.         mov     cx,5
  192. dloop2:
  193.         div     ten
  194.         add     dl,'0'                  ;convert to ascii
  195.         mov     byte ptr [bx],dl
  196.         sub     dx,dx
  197.         inc     bx
  198.         dec     cx
  199.         cmp     cx,0
  200.         jne     dloop2
  201.  
  202. ;       We now have 8 ascii bytes at temp, lsb first that is the freq
  203. ;       We need to pack them into bcd, putting them at label freq
  204.         mov     ah,temp+1
  205.         and     ah,0Fh                  ;convert to bcd
  206.         mov     cl,4
  207.         shl     ah,cl                    ;shift left 4
  208.         mov     al,temp
  209.         and     al,0Fh
  210.         add     ah,al
  211.         mov     freq,ah
  212.  
  213.         mov     ah,temp+3
  214.         and     ah,0Fh                  ;convert to bcd
  215.         shl     ah,cl                    ;shift left 4
  216.         mov     al,temp+2
  217.         and     al,0Fh
  218.         add     ah,al
  219.         mov     freq+1,ah
  220.  
  221.         mov     ah,temp+5
  222.         and     ah,0Fh                  ;convert to bcd
  223.         shl     ah,cl                    ;shift left 4
  224.         mov     al,temp+4
  225.         and     al,0Fh
  226.         add     ah,al
  227.         mov     freq+2,ah
  228.  
  229.         mov     ah,temp+7
  230.         and     ah,0Fh                  ;convert to bcd
  231.         shl     ah,cl                    ;shift left 4
  232.         mov     al,temp+6
  233.         and     al,0Fh
  234.         add     ah,al
  235.         mov     freq+3,ah
  236.  
  237.         mov     cx,10
  238.         mov     bx,offset cmd
  239.         call    putserstr
  240.  
  241.         pop     ax
  242.         pop     ds
  243.         iret
  244. main    endp
  245.  
  246.  
  247. install:
  248.         mov     dx,offset msg1
  249.         mov     ah,9
  250.         int     21h
  251.         mov     dx,offset handler
  252.         mov     al,0D3h
  253.         mov     ah,25h
  254.         int     21h
  255.  
  256.         mov     dx,(offset install - segorg +15) shr 4
  257.         mov     ah,31h
  258.         int     21h
  259.  
  260. msg1    db      'Scan TSR loaded for ICOM IC-735 using Int D3',13,10,'$'
  261.  
  262. code    ends
  263.         end     start
  264.